/**
 * Copyright (c) 2013-2020, tanghailan  (tanghailan@88.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.kanavi.pay.app.controller;

import java.math.BigDecimal;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.kanavi.pay.app.service.PayStrategy;
import com.kanavi.pay.app.PayStrategyFactory;

import lombok.SneakyThrows;

/**
 *
 * <b>PayController.java</b></br>
 *
 * <pre></pre>
 *
 * @author tanghailan tanghailan@88.com
 * @date 2021年03月08日 16:56:30
 * @since JDK 1.8
 */
@RestController
public class PayController {
	@SneakyThrows
	@GetMapping("/pay/{channel}")
	public String pay(@PathVariable(value = "channel") Integer channel) {
		PayStrategyFactory instance = PayStrategyFactory.getInstance();
		PayStrategy payStrategy = instance.create(channel);
		BigDecimal bigDecimal = payStrategy.calRecharge(channel, 1);
		return bigDecimal.toString();
	}
}
